package com.todo.user.application.frontend.controller;

import com.google.api.client.util.Lists;
import com.todo.common.common.entity.CurrentUser;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.common.common.entity.response.page.PageResult;
import com.todo.common.utils.TodoCommonUtils;
import com.todo.user.application.frontend.service.UserInfoAggService;
import com.todo.user.iface.frontend.UserBaseFrontendIface;
import com.todo.user.iface.frontend.request.QueryOtherUserDetailParam;
import com.todo.user.iface.frontend.request.SaveUserRelationParam;
import com.todo.user.iface.frontend.request.UserRelationListParam;
import com.todo.user.iface.frontend.response.BaseUserDetailVO;
import com.todo.user.iface.frontend.response.UserRelationVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/5/13 20:35
 * @description
 */
@RestController
@RequestMapping("/userBase")
@Tag(name = "用户前台接口", description = "用户前台接口")
public class UserBaseFrontendController implements UserBaseFrontendIface {

    @Resource
    private UserInfoAggService userInfoAggService;

    @Override
    @Operation(summary = "查询他人详情数据")
    @PostMapping("/queryOtherUserInfoDetail")
    public BizResponse<BaseUserDetailVO> queryOtherUserInfoDetail(@RequestBody QueryOtherUserDetailParam param) {
        if (param == null || !param.checkParam()) {
            return BizResponse.paramError("调用失败，数据缺失");
        }
        return userInfoAggService.queryOtherUserInfoDetail(param);
    }

    @Override
    @Operation(summary = "新增用户关联信息")
    @PostMapping("/saveUserRelation")
    public BizResponse<Boolean> saveUserRelation(@RequestBody SaveUserRelationParam param) {
        if (param == null || !param.checkParam()) {
            return BizResponse.paramError("调用失败，数据缺失");
        }
        return userInfoAggService.saveUserRelation(param);
    }

    @Override
    @Operation(summary = "查询用户关联信息列表")
    @PostMapping("/queryUserRelationList")
    public PageResult<UserRelationVO> queryUserRelationList(@RequestBody UserRelationListParam param) {
        if (param == null || !param.checkParam()) {
            return PageResult.of(Lists.newArrayList(), 0, 0, 0);
        }
        return userInfoAggService.queryUserRelationList(param);
    }
}
